function debounce(callback, time) {
  let timer = null;

  return function (e) {
    if (timer) {
      clearTimeout(timer);
    }

    timer = setTimeout(() => {
      callback.call(this, e);
    }, time);
  };
}
